﻿<Page:BasePage
    xmlns:Page="clr-namespace:Tfs.OnTheRoad.Pages"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:Mvvm="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"    
    xmlns:Controls="clr-namespace:Tfs.OnTheRoad.Controls"
    xmlns:converters="clr-namespace:Tfs.OnTheRoad.Converters"
	mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
	x:Class="Tfs_OnTheRoad.ProjectOverviewPage"
	FontFamily="{StaticResource PhoneFontFamilyNormal}"
	FontSize="{StaticResource PhoneFontSizeNormal}"
	Foreground="{StaticResource PhoneForegroundBrush}"
	SupportedOrientations="Portrait" Orientation="Portrait"  ApplicationBarButtons="Refresh,About,Back,GoToWorkItem" 
	shell:SystemTray.IsVisible="True">
    <!--Enabling Page Transitions-->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <phone:PhoneApplicationPage.Resources>
        <converters:BuildImageConverter x:Key="BuildImageConverter"></converters:BuildImageConverter>
        <converters:QueryImageConverter x:Key="QueryImageConverter"></converters:QueryImageConverter>
    </phone:PhoneApplicationPage.Resources>
        <!--LayoutRoot contains the root grid where all other page content is placed-->
	<Grid x:Name="LayoutRoot">
        <Controls:HeaderControl></Controls:HeaderControl>
        
        <toolkit:PerformanceProgressBar Height="20" IsIndeterminate="True"  Grid.ColumnSpan="4" Visibility="{Binding Processing, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        <controls:Panorama Title="{Binding PageTitle}" Foreground="{StaticResource PhoneAccentBrush}" SelectionChanged="Panorama_SelectionChanged" x:Name="projectPanorama">
            <controls:PanoramaItem Padding="0,-30,0,0" Foreground="{StaticResource PhoneForegroundBrush}"  x:Name="summaryItem">
                <Grid>
                    <TextBlock Text="Summary" Style="{StaticResource PhoneTextTitle1Style}"></TextBlock>
                    <Controls:WorkItemsOverviewChartControl Opacity=".9" x:Name="WorkItemsChart"></Controls:WorkItemsOverviewChartControl>
                </Grid>
            </controls:PanoramaItem>

            <controls:PanoramaItem Header="Builds" Foreground="{StaticResource PhoneForegroundBrush}" x:Name="buildsItem">
                <Grid Margin="10,0,10,0" x:Name="buildsGrid">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <ListBox toolkit:TiltEffect.IsTiltEnabled="True" x:Name="BuildsListBox" Grid.Row="0" ItemsSource="{Binding Items}" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Interactivity:Interaction.Triggers>
                            <Interactivity:EventTrigger EventName="SelectionChanged">
                                <Mvvm:EventToCommand Command="{Binding NavigateToBuild}" PassEventArgsToCommand="True">
                                </Mvvm:EventToCommand>
                            </Interactivity:EventTrigger>
                        </Interactivity:Interaction.Triggers>
                        <ListBox.Template>
                            <ControlTemplate TargetType="ListBox">
                                <ScrollViewer>
                                    <StackPanel>
                                        <ItemsPresenter/>
                                        <HyperlinkButton Content="Load More ..." Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding LoadMoreResultsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource HyperlinkButtonNotUnderlineStyle}">
                                            <Interactivity:Interaction.Triggers>
                                                <Interactivity:EventTrigger EventName="Click">
                                                    <Mvvm:EventToCommand Command="{Binding LoadMoreItems}"></Mvvm:EventToCommand>
                                                </Interactivity:EventTrigger>
                                            </Interactivity:Interaction.Triggers>
                                        </HyperlinkButton>
                                    </StackPanel>
                                </ScrollViewer>
                            </ControlTemplate>
                        </ListBox.Template>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                                            <ColumnDefinition Width="*"></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Column="0" Width="28"  Source="{Binding Status,Converter={StaticResource BuildImageConverter}}" VerticalAlignment="Center"></Image>
                                        <TextBlock Grid.Column="1" Text="{Binding Number}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3StyleWithoutForeground}"/>
                                    </Grid>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Definition}" TextWrapping="Wrap" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextSubtleStyle}" Margin="0" />
                                    </StackPanel>                                    
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="Completed - " Style="{StaticResource PhoneTextSubtleStyle}" Margin="12,0,6,0" />
                                        <TextBlock Text="{Binding FinishTime}" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextSubtleStyle}" Margin="0" />
                                    </StackPanel>                                    
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <TextBlock Grid.Row="0" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=true}" Padding="10" TextWrapping="Wrap" FontSize="30" Text="{Binding NoResultsFoundMessage}"></TextBlock>                    
                </Grid>
            </controls:PanoramaItem>

            <controls:PanoramaItem Header="Changesets" Foreground="{StaticResource PhoneForegroundBrush}" x:Name="changesetsItem">
                <Controls:ChangesetsListControl ProgressBarVisibility="Collapsed"></Controls:ChangesetsListControl>               
            </controls:PanoramaItem>

            <controls:PanoramaItem Header="Branches" Foreground="{StaticResource PhoneForegroundBrush}" x:Name="branchesItem">
                <Grid x:Name="branchesGrid" Grid.Row="2" Grid.ColumnSpan="2" Margin="10,0,10,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <ListBox toolkit:TiltEffect.IsTiltEnabled="True" x:Name="BranchesListBox" Grid.Row="0" ItemsSource="{Binding Items}" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Interactivity:Interaction.Triggers>
                            <Interactivity:EventTrigger EventName="SelectionChanged">
                                <Mvvm:EventToCommand Command="{Binding NavigateToBranch}" PassEventArgsToCommand="True">
                                </Mvvm:EventToCommand>
                            </Interactivity:EventTrigger>
                        </Interactivity:Interaction.Triggers>
                        <ListBox.Template>
                            <ControlTemplate TargetType="ListBox">
                                <ScrollViewer>
                                    <StackPanel>
                                        <ItemsPresenter/>
                                        <HyperlinkButton Content="Load More ..." Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding LoadMoreResultsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource HyperlinkButtonNotUnderlineStyle}">
                                            <Interactivity:Interaction.Triggers>
                                                <Interactivity:EventTrigger EventName="Click">
                                                    <Mvvm:EventToCommand Command="{Binding LoadMoreItems}"></Mvvm:EventToCommand>
                                                </Interactivity:EventTrigger>
                                            </Interactivity:Interaction.Triggers>
                                        </HyperlinkButton>
                                    </StackPanel>
                                </ScrollViewer>
                            </ControlTemplate>
                        </ListBox.Template>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                                            <ColumnDefinition Width="*"></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition Height="*"></RowDefinition>
                                        </Grid.RowDefinitions>
                                        <Image Grid.Row="0" Grid.Column="0" Width="24"  Source="/Images/BranchIcon.png" VerticalAlignment="Center"></Image>
                                        <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Path}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3StyleWithoutForeground}"/>
                                        <TextBlock Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Text="{Binding DateCreated}" Foreground="{StaticResource PhoneAccentBrush}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" Margin="0" />
                                    </Grid>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <TextBlock Grid.Row="0" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=true}" Padding="10" TextWrapping="Wrap" FontSize="30" Text="{Binding NoResultsFoundMessage}"></TextBlock>
                </Grid>
            </controls:PanoramaItem>
            
            <controls:PanoramaItem Header="Queries" Foreground="{StaticResource PhoneForegroundBrush}" x:Name="queriesItem">
                <Grid Margin="10,0,10,0" x:Name="queriesGrid">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <ListBox toolkit:TiltEffect.IsTiltEnabled="True" x:Name="QueriesListBox" Grid.Row="0" ItemsSource="{Binding Items}" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Interactivity:Interaction.Triggers>
                            <Interactivity:EventTrigger EventName="SelectionChanged">
                                <Mvvm:EventToCommand Command="{Binding NavigateToWorkItemsOverview}" PassEventArgsToCommand="True">
                                </Mvvm:EventToCommand>
                            </Interactivity:EventTrigger>
                        </Interactivity:Interaction.Triggers>
                        <ListBox.Template>
                            <ControlTemplate TargetType="ListBox">
                                <ScrollViewer>
                                    <StackPanel>
                                        <ItemsPresenter/>
                                        <HyperlinkButton Content="Load More ..." Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding LoadMoreResultsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource HyperlinkButtonNotUnderlineStyle}">
                                            <Interactivity:Interaction.Triggers>
                                                <Interactivity:EventTrigger EventName="Click">
                                                    <Mvvm:EventToCommand Command="{Binding LoadMoreItems}"></Mvvm:EventToCommand>
                                                </Interactivity:EventTrigger>
                                            </Interactivity:Interaction.Triggers>
                                        </HyperlinkButton>
                                    </StackPanel>
                                </ScrollViewer>
                            </ControlTemplate>
                        </ListBox.Template>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                                            <ColumnDefinition Width="*"></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition Height="*"></RowDefinition>
                                        </Grid.RowDefinitions>
                                        <Image Grid.Row="0" Grid.Column="0" Width="24"  Source="{Binding QueryType,Converter={StaticResource QueryImageConverter}}" VerticalAlignment="Center"></Image>
                                        <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3StyleWithoutForeground}"/>
                                        <TextBlock Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Text="{Binding Path}" Foreground="{StaticResource PhoneAccentBrush}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" Margin="0" />
                                    </Grid>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <TextBlock Grid.Row="0" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=true}" Padding="10" TextWrapping="Wrap" FontSize="30" Text="{Binding NoResultsFoundMessage}"></TextBlock>
                </Grid>
            </controls:PanoramaItem>
				
		</controls:Panorama>
        <Controls:FindWorkItemPanel Visibility="Collapsed" VerticalAlignment="Top" />
	</Grid>
</Page:BasePage>